﻿@model ADZ_BrandMaster
@{
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    var viewModel = Model ?? new ADZ_BrandMaster();
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" action="@Url.Action("add", "brand")" me method="post" class="definewidth m20" enctype="multipart/form-data">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td colspan="2" style="width:50%">
                <h5>@ViewBag.Title</h5>
                <input type="hidden" value="@viewModel.brand_id" name="brand_id" id="brand_id" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">品牌LOGO<em></em></td>
            <td>
                <div id="oldimg" style="display:none">
                    <a href="javascript:void(0)" onclick="showimg('@ImageFileBiz.GetImg(Model.logo_img_url)')"> <img src="@ImageFileBiz.GetImg(Model.logo_img_url, "small")" alt=""></a>
                    <br />
                    <input name="logo_img_url" type="hidden" value="@Model.logo_img_url" />
                    <button type="button" name="delimg" class="btn btn-primary table-bordered delimg" param-imgkey="@Model.logo_img_url">删除此图</button>
                </div>
                <div id="newimg">
                    <img src="" alt="" id="inputFileSrc1" />
                    <a href="javascript:;" class="a-upload" id="inputFileSrc1_btn">
                        <input type="file" name="file" onchange="handleFiles(this.files,'inputFileSrc1')" accept="image/*">
                    </a>
                </div>
                <script>
                    $(document).ready(function () {
                        if ($("#brand_id").val() > 0) {
                            $("#oldimg").show();
                            $("#newimg").hide();

                            if ($("#oldimg") !== undefined) {
                                $("#newimg").hide();
                            }
                        }

                        $('.delimg').click(function () {
                            deleteParentElement(this);
                            $("#newimg").show();
                        });
                    });
                </script>
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">品牌名称<em>*</em></td>
            <td>
                <input type="text" name="brand_name" style="width:300px;" value="@Model.brand_name" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">品牌英文名称</td>
            <td>
                <input type="text" name="brand_name_en" style="width:300px;" value="@Model.brand_name_en" />
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">是否显示<em>*</em></td>
            <td>
                <select id="is_show" name="is_show">
                    @{
                        dc = new Dictionary<string, string>();
                        dc.Add("0", "不显示");
                        dc.Add("1", "显示");
                    }
                    @HtmlPagerHelper.ShowSelectOpton(dc, viewModel.is_show.ToString());
                </select>&nbsp;
            </td>
        </tr>
        <tr>
            <td width="6%" class="tableleft">品牌说明</td>
            <td>
                <textarea name="brand_content" style="width:80%;" maxlength="250" cols="4">@viewModel.brand_content</textarea>
            </td>
        </tr>
        <tr>
            <td class="tableleft"></td>
            <td colspan="3">
                <p><span id="spMsg"></span></p>
                <button type="submit" class="btn btn-primary">保存</button> &nbsp;&nbsp;
                @if (viewModel.brand_id > 0)
                {
                    <button type="button" class="btn btn-success" name="backid" id="backid">返回</button>
                }
            </td>

        </tr>
    </table>
    <script>
        BUI.use('bui/overlay', function (overlay) {
            $(function () {
                var validator = $('form').validate({
                    errorLabelContainer: $("#errorContainer"),
                    errorElement: "span",
                    rules: {
                        brand_name: { required: true }
                    },
                    messages: {
                        brand_name: { required: "请输入品牌名称" }
                    },
                    submitHandler: function (form) {
                        $(form).ajaxSubmit(function (result) {
                            ShowActionResult(result, function () { self.location = document.referrer; });
                        });
                    }
                });

            });
        });
    </script>
</form>
